﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Entity
{
    /// <summary>
    /// API返回值
    /// </summary>
    public class ApiResult
    {
        public int Code { get; set; } = 200;
        public bool IsSuccess { get; set; } = true;
        public string Message { get; set; } = "success";
        public object Data { get; set; }

        /// <summary>
        /// 返回成功的数据
        /// </summary>
        /// <param name="message"></param>
        /// <returns></returns>
        public static ApiResult Success(object data = null,string message = "success")
        {
            return new ApiResult() { Message = message,Data = data };
        }

        public static ApiResult Fail(string message = "操作异常")
        {
            return new ApiResult() {IsSuccess = false,Message = message};
        }
    }
}
